require "test/unit"
class AboutTriangleProject2 < Test::Unit::TestCase
  class TriangleError < NameError
  end

  def triangle(a, b, c)
    triangle = if (a <= 0 or b <= 0 or c <= 0)
                 raise TriangleError.new
               elsif((a + b) <= c or (b + c) <= a or (a + c) <= b)
                 raise TriangleError.new
               elsif(a == b && a == c && a > 0 && b > 0)
                 :equilateral
               elsif(a == b && a != c && a > 0 && c > 0)
                 :isosceles
               elsif(a == c && a != b && a > 0 && b > 0) 
                 :isosceles
               elsif(b == c && a != b && a > 0 && b > 0)
                 :isosceles
               elsif(a != b && a != c && b != c && a > 0 && b > 0 && c > 0)
                 :scalene
               end   
  end
  


  def test_string1
    assert_raise (TriangleError) do triangle(0, 0, 0) end   
  end

  def test_illegal_triangles_throw_exceptions_negative_side
    assert_raise(TriangleError) do triangle(3, 4, -5) end
  end

  def test_illegal_triangles_throw_exceptions_one_side_too_long
    assert_raise(TriangleError) do triangle(1, 1, 3) end
  end

  def test_illegal_triangles_throw_exceptions_one_side_same_length_as_other_two
    assert_raise(TriangleError) do triangle(2, 4, 2) end
  end

  def test_string2
    assert_equal :equilateral, triangle(2, 2, 2)
    assert_equal :equilateral, triangle(10, 10, 10)
  end

  def test_string3
    assert_equal :isosceles, triangle(3, 4, 4)
    assert_equal :isosceles, triangle(4, 3, 4)
    assert_equal :isosceles, triangle(4, 4, 3)
  end

  def test_string4
    assert_equal :scalene, triangle(3, 4, 5)
    assert_equal :scalene, triangle(10, 11, 12)
    assert_equal :scalene, triangle(5, 4, 2)
  end

end
